package com.example.demo.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xiaohei.crm.common.result.Result;
import com.xiaohei.crm.dao.EnterpriseServices;
import com.xiaohei.crm.service.EnterpriseServicesService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;


@RestController
@CrossOrigin
@RequiredArgsConstructor
public class EnterpriseServicesController {
    private final EnterpriseServicesService enterpriseServicesService;
    /**
     * 分页查询区域信息
     * @return
     */
    @GetMapping("/enterpriseServices/findByPage")
    public Result<IPage> findByPage(){
        return enterpriseServicesService.findByPage();
    }
    /**
     * 添加用户
     * @param
     * @return
     */
    @PostMapping("/enterpriseServices")
    public Result save(@RequestBody EnterpriseServices requestParams) {
        enterpriseServicesService.saveMaterial(requestParams);
        return Result.ok();
    }

    /**
     * 修改区域信息
     * @param
     * @return
     */
    @PutMapping("/enterpriseServices")
    public Result update(@RequestBody EnterpriseServices requestParams){
        enterpriseServicesService.updateMaterialById(requestParams);
        return Result.ok();
    }

    /**
     * 逻辑删除区域
     * @param
     * @return
     */
    @DeleteMapping("enterpriseServices/{id}")
    public Result<String> deleteByUsername(@PathVariable("id") String id){
        enterpriseServicesService.removeByMaterialId(id);
        return Result.ok();
    }

}
